import { Canvas2DApplication } from "./Application";

function ch3() {
    let canvas = document.getElementById("canvas") as HTMLCanvasElement
    let app = new Canvas2DApplication(canvas);

    function timerCallback(id: number, data: string): void {
        console.log("定时器", id, data, new Date().toTimeString())
    }

    let timer0 = app.addTimer(timerCallback, 3, true, "timer0的参数")
    let timer1 = app.addTimer(timerCallback, 5, false, "timer1的参数")
    console.log(app.timers);

    let startButton = document.getElementById("start") as HTMLButtonElement;

    startButton.onclick = () => {
        app.start()
    }
    let stopButton = document.getElementById("stop") as HTMLButtonElement;

    stopButton.onclick = () => {
        app.removeTimer(timer1);
        console.log(app.timers)

        let id = app.addTimer(timerCallback, 10, true, "timer2的参数");
        console.log("id", id)
    }

}

export {
    ch3
}